#include <bits/stdc++.h>
#include <iterator>
#include <numeric>

using namespace std;

class Solution {
public:
    long long minimumRemoval(vector<int>& beans)
    {
        sort(begin(beans), end(beans));
        long long res = LLONG_MAX, sum = accumulate(begin(beans), end(beans), 0LL);
        for (int i = 0, len = size(beans); i < len; ++i) res = min(res, sum - 1LL * (len - i) * beans[i]);
        return res;
    }

private:
};

int main()
{
    [[maybe_unused]] Solution solution;
    return 0;
}
